#!/bin/bash

method=$(eval echo '$'METHOD)
query=UNKOWN
if [ $method == GET ]
then
    query=$(eval echo '$'QUERY)
elif [ $method == POST ]
then
    content_length=$(eval echo '$'CONTENT_LENGTH)
     read query
else
    echo "error"
fi

query=${query:6} # 字符串截取

echo "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\">"
echo "<title>shell结果</title>"
echo "<link rel=\"shortcut icon\" href=\"favicon.ico\" />"
echo "<link rel=\"apple-touch-icon\" href=\"favicon.ico\" />"
echo "</head><body>"
echo "<br>"
echo "<a href=\"/\">首页 </a>"
echo "<a href=\"/login.html\">登录注册 </a>"
echo "<a href=\"/shell.html\">远程连接 </a><br>"
echo "<h2>执行结果</h2><br>"
echo "<h4> [ $query ] $($query)<h4>"
echo "</body></html>"
